//
//  SNCompilePlanOtherCell.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/26.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNPesticideInformationController.h"
#import "SNFertilizerInformationController.h"
#import "UIImageView+TapGesture.h"
#import "SNCompilePlanOtherCell.h"
#import "SNPlanListLabel.h"
#import "SNCompilePlanOtherButton.h"
@interface SNCompilePlanOtherCell()
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconImageViewHeightLayoutConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconImageViewWidthLayoutConstraint;
@property (weak, nonatomic) IBOutlet SNPlanListLabel *rightLabel;

@property (weak, nonatomic) IBOutlet SNCompilePlanOtherButton *moreButton;

@end
@implementation SNCompilePlanOtherCell
- (void)configCellWithTitle:(NSString *)title imageName:(NSString *)imageName indexPath:(NSIndexPath *)indexPath{
    self.iconImageView.image = [UIImage imageNamed:imageName];
    if (indexPath.section == 3) {
        self.leftLabel.text = [NSString stringWithFormat:@"%@",title];
        
        UIImage * image = self.iconImageView.image;
        self.iconImageViewWidthLayoutConstraint.constant = 20 ;
        self.iconImageViewHeightLayoutConstraint.constant = self.iconImageViewWidthLayoutConstraint.constant * image.size.height / image.size.width;
        return;
    }
    self.leftLabel.text = [NSString stringWithFormat:@"* %@",title];
    
    [SNUtils specialLabelWithstring:self.leftLabel.text keyString:@"*" label:self.leftLabel color:HexRGB(0xFF5D04)];
    
    
    UIImage * image = self.iconImageView.image;
    self.iconImageViewWidthLayoutConstraint.constant = 15;
    self.iconImageViewHeightLayoutConstraint.constant = self.iconImageViewWidthLayoutConstraint.constant * image.size.height / image.size.width;
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [SNUtils specialLabelWithstring:self.leftLabel.text keyString:@"*" label:self.leftLabel color:HexRGB(0xFF5D04)];
    
    UIImage * image = self.iconImageView.image;
    
    self.iconImageViewHeightLayoutConstraint.constant = 15 * image.size.height / image.size.width;
    
    self.rightLabel.sn_tapBlock = ^(){
        
        NSLog(@"%@ | %s",self.class,__func__);
        if([self.leftLabel.text containsString:@"肥料信息"]){
            SNFertilizerInformationController * vc = [SNFertilizerInformationController new];
            
            [self.nav pushViewController:vc animated:YES];
        }else if ([self.leftLabel.text containsString:@"农药信息"]){
            SNPesticideInformationController * vc = [SNPesticideInformationController new];
            
            [self.nav pushViewController:vc animated:YES];
        }
    };
    
    [self.moreButton addTarget:self action:@selector(moreButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
}
- (void)moreButtonClicked:(SNCompilePlanOtherButton *)sender
{
    NSLog(@"%@ | %s",self.class,__func__);
}
@end
